﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using CarShop.Domain.Entities;

namespace CarShop.Data.EntityFramework.Mappings
{
    internal class RoleConfiguration : EntityBaseConfiguration<Role, int>
    {
        public RoleConfiguration()
        {
            Property(r => r.Name).IsRequired().HasMaxLength(50);

            HasMany(r => r.Users)
                .WithMany(u => u.Roles)
                .Map(map => map.MapLeftKey("RoleId").MapRightKey("UserId").ToTable("User_Role"));
        }
    }
}
